/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-03-10     金鹏       the first version
 */
#include "led.h"
extern int cm_switch;

static rt_thread_t led_handl = RT_NULL;           /* LED线程句柄*/
/*
 * LED_Entry
 * @Param NULL
 *
 * Change Logs:
 * Date           Author     Notes
 * 2025-5-12     金鹏        LED线程
 */
void LED_Entry(void *parameter)
{
    int Led_WIfi_yellow;
    int Led_4G_green;

    Led_WIfi_yellow = rt_pin_get("PE.3");
    Led_4G_green = rt_pin_get("PE.2");

    rt_pin_mode(Led_WIfi_yellow, 0);
    rt_pin_mode(Led_4G_green, 0);

    while(1){
        if(cm_switch == 0){
           rt_pin_write(Led_WIfi_yellow, 1);
           rt_pin_write(Led_4G_green, 0);
        }
        else{
           rt_pin_write(Led_4G_green, 1);
           rt_pin_write(Led_WIfi_yellow, 0);
        }
        rt_thread_mdelay(100);
    }
}

/*
 * LED_Test
 * @Param NULL
 *
 * Change Logs:
 * Date           Author     Notes
 * 2025-3-10       金鹏      LED灯测试
 */
void LED_Test()
{
    /* 创建LED线程*/
    led_handl = rt_thread_create("led",
                                   LED_Entry,RT_NULL,
                                   ENTRY_STACK_SIZE-1024,
                                   ENTRY_PRI,
                                   ENTRY_TICK);
    /* LOG*/
    if(led_handl != RT_NULL){
        rt_kprintf("led thread create successful!!\n");

        /* 启动LED线程*/
        rt_thread_startup(led_handl);
    }else{
        rt_kprintf("led thread create failed!!\n");

        return -RT_ERROR;
    }
}
